package net.vkits.common.push.umeng.android;

/**
 * Created by ethan-liu on 2016/11/23.
 */
public class AndroidBodyEntity {
    private final String ticker;
    private final String title;
    private final String text;
    private final String icon;
    private final String largeIcon;
    private final String img;
    private final String sound;
    private final String builder_id;
    private final String play_vibrate;
    private final String play_lights;
    private final String play_sound;
    private final AfterOpenAction after_open;
    private final String url;
    private final String activity;
    private final String custom;

    public enum AfterOpenAction{
        go_app,//打开应用
        go_url,//跳转到URL
        go_activity,//打开特定的activity
        go_custom//用户自定义内容。
    }

    private AndroidBodyEntity(String ticker, String title, String text, String icon, String largeIcon, String img, String sound, String builder_id, String play_vibrate, String play_lights, String play_sound, AfterOpenAction after_open, String url, String activity, String custom) {
        this.ticker = ticker;
        this.title = title;
        this.text = text;
        this.icon = icon;
        this.largeIcon = largeIcon;
        this.img = img;
        this.sound = sound;
        this.builder_id = builder_id;
        this.play_vibrate = play_vibrate;
        this.play_lights = play_lights;
        this.play_sound = play_sound;
        this.after_open = after_open;
        this.url = url;
        this.activity = activity;
        this.custom = custom;
    }

    public static class Builder{
        private String ticker;
        private String title;
        private String text;
        private String icon = null;
        private String largeIcon = null;
        private String img = null;
        private String sound = null;
        private String builder_id = "0";
        private String play_vibrate;
        private String play_lights;
        private String play_sound;
        private AfterOpenAction after_open;
        private String url;
        private String activity;
        private String custom;

        public Builder(String ticker, String title, String text, AfterOpenAction after_open) {
            // 必填 通知栏提示文字
            this.ticker = ticker;
            // 必填 通知标题
            this.title = title;
            // 必填 通知文字描述
            this.text = text;
            /*  必填 值可以为:
                "go_app": 打开应用
                "go_url": 跳转到URL
                "go_activity": 打开特定的activity
                "go_custom": 用户自定义内容。
            */
            this.after_open = after_open;
        }

        public Builder icon(String icon) {
        /*  可选 状态栏图标ID, R.drawable.[smallIcon],
            如果没有, 默认使用应用图标。图片要求为24*24dp的图标,或24*24px放在drawable-mdpi下。注意四周各留1个dp的空白像素
        */
            this.icon = icon;
            return this;
        }

        public Builder largeIcon(String largeIcon) {
        /*  可选 通知栏拉开后左侧图标ID, R.drawable.[largeIcon].
            图片要求为64*64dp的图标,可设计一张64*64px放在drawable-mdpi下,注意图片四周留空，不至于显示太拥挤
        */
            this.largeIcon = largeIcon;
            return this;
        }

        public Builder img(String img) {
        // 可选 通知栏大图标的URL链接。该字段的优先级大于largeIcon。该字段要求以http或者https开头
            this.img = img;
            return this;
        }

        public Builder sound(String sound) {
        /*可选 通知声音，R.raw.[sound].
        如果该字段为空，采用SDK默认的声音, 即res/raw/下的
                umeng_push_notification_default_sound声音文件
        如果SDK默认声音文件不存在，
        则使用系统默认的Notification提示音。*/
            this.sound = sound;
            return this;
        }

        public Builder builder_id(String builder_id) {
        /*可选 默认为0，用于标识该通知采用的样式。使用该参数时,
        开发者必须在SDK里面实现自定义通知栏样式。*/
            this.builder_id = builder_id;
            return this;
        }

        public Builder play_vibrate(String play_vibrate) {
        /*可选 收到通知是否震动,默认为"true".
        注意，"true/false"为字符串*/
            this.play_vibrate = play_vibrate;
            return this;
        }

        public Builder play_lights(String play_lights) {
            // 可选 收到通知是否闪灯,默认为"true"
            this.play_lights = play_lights;
            return this;
        }

        public Builder play_sound(String play_sound) {
            // 可选 收到通知是否发出声音,默认为"true"
            this.play_sound = play_sound;
            return this;
        }

        public Builder url(String url) {
        /*可选 当"after_open"为"go_url"时，必填。
        通知栏点击后跳转的URL，要求以http或者https开头*/
            this.url = url;
            return this;
        }

        public Builder activity(String activity) {
        /*可选 当"after_open"为"go_activity"时，必填。
        通知栏点击后打开的Activity*/
            this.activity = activity;
            return this;
        }

        public Builder custom(String custom) {
        /*可选 display_type=message, 或者
        display_type=notification且
        "after_open"为"go_custom"时，
        该字段必填。用户自定义内容, 可以为字符串或者JSON格式。*/
            this.custom = custom;
            return this;
        }

        public AndroidBodyEntity createAndroidBodyEntity() {
            return new AndroidBodyEntity(ticker,title,text,icon,largeIcon,
                    img,sound,builder_id,play_vibrate,play_lights,
                    play_sound,after_open, url,activity,custom);
        }
    }

    public String getTicker() {
        return ticker;
    }

    public String getTitle() {
        return title;
    }

    public String getText() {
        return text;
    }

    public String getIcon() {
        return icon;
    }

    public String getLargeIcon() {
        return largeIcon;
    }

    public String getImg() {
        return img;
    }

    public String getSound() {
        return sound;
    }

    public String getBuilder_id() {
        return builder_id;
    }

    public String getPlay_vibrate() {
        return play_vibrate;
    }

    public String getPlay_lights() {
        return play_lights;
    }

    public String getPlay_sound() {
        return play_sound;
    }

    public AfterOpenAction getAfter_open() {
        return after_open;
    }

    public String getUrl() {
        return url;
    }

    public String getActivity() {
        return activity;
    }

    public String getCustom() {
        return custom;
    }
}
